/**
 * Created by JuntaoYi
 * Date 2020/3/30
 */
import React, {Component} from 'react';
import {BrowserRouter as Router,Redirect} from 'react-router-dom';
import { renderRoutes } from 'react-router-config';
import routes from "./routes";

export default class AppRouter extends Component {
    getRoutes = () => {
        return routes;
    }

    render() {
        const userRoutes = this.getRoutes();
        return (
            // <Router>
            //     <Switch>
            //         {
            //             userRoutes.map(item => {
            //                 const {path,component} = item;
            //                 return <Route key={path} path={path} component={component}></Route>
            //             })
            //         }
            //     </Switch>
            // </Router>
            <Router>
                <Redirect exact to="/login" from='/' />
                {renderRoutes(userRoutes)}
            </Router>
        )
    }
}
